﻿using System;
using System.Text;

namespace XBee.Communications
{
    public class TestData : CommunicationData
    {
        #region Construcctor
        public TestData() { }
        public TestData(bool data)
        {
            this.booldata = data;
        }
        #endregion

        #region Members
        private bool booldata = false;
        #endregion

        #region Properties
        public bool BoolData
        {
            get { return booldata; }
            set { booldata = value; }
        }
        #endregion

        #region Overrided Methods
        public override string Serialize()
        {
            string res = string.Empty;
            res += (char)this.ByteStartDelimiter;
            res += booldata ? "ON" : "OFF";
            res += (char)this.ByteFinishDelimiter;
            return res;
        }

        public override ICommunicationData Deserialize(string sentence)
        {
            TestData res = new TestData();
            sentence = sentence.Trim();
            sentence = RemoveDelimiters(sentence);
            if (sentence == "ON")
                res.BoolData = true;
            else
                res.BoolData = false;
            return res;
        }
        #endregion
    }
}
